<?php 
require 'Controller.php ';
require './admin/Model/TypeModel.php';
class TypeController extends Controller
{
	function __Construct()
	{
		parent::__Construct();
		$this->mod='videotype';
		$this->model=new TypeModel();
	}
	function listtypes()
	{
		$data =$this->model->getList();
		$this->assign('videotype',$data);
		$this->display(); 
	}
	function typeform()
	{
		$this->display(); 
	}
	function add2()
	{
		$data = $_POST;
		$result = $this->model->add2($data);
		if($result){
			echo '添加成功 <a href="index.php?c=type&m=listtypes">如果没有跳转，请点这里跳转</a>';
			header("refresh:3;url='index.php?c=type&m=listtypes'");
		}
		else{
			echo "添加失败！<br/>";
			echo "<a href='index.php?c=type&m=videoform'>返回</a>";
		}
	}
	function typemod()
	{
		$id = $_GET['id'];
		$result = $this->model->getTypeByID($id);
		$this->assign('videotype',$result);
		$this->display(); 
	}
	function update2()
	{
		$data = $_POST;
		$result = $this->model->update2($data);
		if($result){
			echo '更新成功 <a href="index.php?c=type&m=listtypes">如果没有跳转，请点这里跳转</a>';
			header("refresh:3;url='index.php?c=type&m=listtypes'");
		}
		else{
			echo "更新失败！<br/>";
			echo "<a href='index.php?c=type&m=typemod&id=".$data['id']."'>返回</a>";
		}
	}
	function delete2()
	{
		$id = $_GET['id'];
		$result = $this->model->delete2($id);
		if($result){
			echo '删除成功 <a href="index.php?c=type&m=listtypes">如果没有跳转，请点这里跳转</a>';
			header("refresh:3;url='index.php?c=type&m=listtypes'");
		}
		else{
			echo "删除失败！<br/>";
			echo "<a href='index.php?c=type&m=listtypes'>返回</a>";
		}
		
	}
}

?>

